package com.junjie.services.impl;

import com.junjie.dao.ApartmentDao;
import com.junjie.entity.Apartment;
import com.junjie.services.ApartmentService;
import com.junjie.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ApartmentServiceImpl implements ApartmentService {

    @Autowired
    private ApartmentDao apartmentDao;

    //公寓信息查询万能接口
    @Override
    public List<Apartment> selectApartment(Apartment apartment) {
        return apartmentDao.getApartment(apartment);
    }

    //查询一条公寓信息
    @Override
    public Apartment getOneApartment(Apartment apartment) {
        return apartmentDao.getOneApartment(apartment);
    }

    //增加一条公寓信息
    @Override
    public CommonResult addApartment(Apartment apartment) {
        return new CommonResult(200, "添加成功！", apartmentDao.addApartment(apartment));
    }

    //修改该一条公寓信息
    @Override
    public CommonResult<Integer> updateApartment(Apartment apartment) {
        return new CommonResult(200, "信息修改成功！", apartmentDao.updateApartment(apartment));
    }

    //删除一条公寓信息
    @Override
    public CommonResult<Integer> deleteApartment(Integer id) {
        return new CommonResult(200, "删除成功！", apartmentDao.deleteApartment(id));
    }

}
